<template>
<el-container class="container">
    <!--头部区域-->
    <el-header>
        <div class="header">
            <span>电商后台管理系统</span>
            <el-button type="info" @click="loginOut">退出</el-button>
        </div>
    </el-header>
    <!--页面主体区域-->
    <el-container>
        <!--侧边栏-->
        <el-aside :width="isCollapse ? '64px' : '200px'">
            <!-- 折叠 -->
            <div class="toggle-button" @click="toggerCollapse">|||</div>
            <!-- 侧边栏菜单区域
            unique-opened  是否只保持一个子菜单的展开
            collapse 是否水平折叠收起菜单
            collapse-transition 是否开启折叠动画
            router  是否使用 vue-router 的模式，启用该模式会在激活导航时以 index 作为 path 进行路由跳转
            -->
            <el-menu background-color="#333744" text-color="#fff" active-text-color="#409EFF" unique-opened :collapse="isCollapse" :collapse-transition="false" router :default-active="activePath">
                <!-- 一级菜单 -->
                <el-submenu>
                    <template slot="title">
                        <span>用户管理</span>
                    </template>
                    <el-menu-item :index="'/user'">
                        <template slot="title">
                            <span>用户列表</span>
                        </template>
                    </el-menu-item>
                </el-submenu>
                <el-submenu>
                    <template slot="title">
                        <span>权限管理</span>
                    </template>
                    <el-menu-item :index="'/roles'">
                        <template slot="title">
                            <span>角色列表</span>
                        </template>
                    </el-menu-item>
                    <el-menu-item :index="'/rights'">
                        <template slot="title">
                            <span>权限列表</span>
                        </template>
                    </el-menu-item>
                </el-submenu>
            </el-menu>
        </el-aside>
        <!--右侧内容主体-->
        <el-main>
            <!-- 路由占位符 -->
            <router-view></router-view>
        </el-main>
    </el-container>
</el-container>
</template>

<script>
export default {
    name: 'home',
    data() {
        return {
            isCollapse: false,
        }

    },
    methods: {
        toggerCollapse() {
            this.isCollapse = !this.isCollapse
        },
        loginOut() {
            this.$router.push('/login')
        }
    }
}
</script>

<style scoped>
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 10px;
    color: rgb(236, 239, 247);
    font-size: 1.5rem;
}

.el-container {
    margin: 0px;
    padding: 0px;
}

.el-header {
    background-color: #373d41;
    color: #333;
    /* line-height: 60px; */
}

.el-aside {
    background-color: #333744;
    height: 800px;
    box-sizing: border-box;
}

.el-main {
    background-color: #eaedf1;
    height: 800px;
    padding: 0px;
    box-sizing: border-box;
}

.toggle-button {
    background-color: #4a5064;
    font-size: 10px;
    line-height: 24px;
    color: #fff;
    text-align: center;
    letter-spacing: 0.2em;
}
</style>
